<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=1000, initial-scale=1.0, maximum-scale=1.0">
	    <!-- Loading Bootstrap -->
	    <link href="public/admin/Flat/dist/css/vendor/bootstrap.min.css" rel="stylesheet">
	    <!-- Loading Flat UI -->
	    <link href="public/admin/Flat/dist/css/flat-ui.css" rel="stylesheet">
	    <link href="public/admin/Flat/docs/assets/css/demo.css" rel="stylesheet">
	    <link rel="shortcut icon" href="public/admin/Flat/img/favicon.ico">

			
	</head>
	<body>
		<form action="" method="post" >
		<div class="alert alert-success">添加广告</div>
		<div class="form-group">
			<label for="exampleInputEmail1">广告名称</label>
			<input id="exampleInputEmail1" class="form-control" type="text" name="alname">
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">网址</label>
			<input id="exampleInputEmail1" class="form-control" type="text" name="allink">
		</div>
		<!--图片上传组件-->
		<div class="form-group" style="height: 140px;">
			<div class="col-sm-10">
    <div class="input-group">
        <input type="text" class="form-control" name="thumb" readonly="" value="">
        <div class="input-group-btn">
            <button onclick="upImage(this)" class="btn btn-default" type="button">选择图片</button>
        </div>
    </div>
    <div class="input-group" style="margin-top:5px;">
         <img src="resource/images/nopic.jpg" class="img-responsive img-thumbnail" width="150">
        <em class="close" style="position:absolute; top: 0px; right: -14px;" title="删除这张图片" onclick="removeImg(this)">×</em>
    </div>
</div>
		</div>
		<!--图片上传结束-->
		<div class="form-group">
			<label for="exampleInputEmail1">排序</label>
			<input id="exampleInputEmail1" class="form-control" type="text" name="sort" value="10">
		</div>
		<input type="hidden" name="aid" id="aid" value="{{$_GET['aid']}}" />
		<button class="btn btn-primary btn-block" type="submit"> 确定 </button>
		</form>
		
		
		
		<!--框架样式-->	  
		<script src="resource/hdjs/js/angular.min.js"></script>
		<link href="resource/hdjs/css/font-awesome.min.css" rel="stylesheet">
		<script src="resource/hdjs/js/jquery.min.js"></script>
		<script src="resource/hdjs/app/util.js"></script>
		<script src="resource/hdjs/require.js"></script>
		<script src="resource/hdjs/app/config.js"></script>	
			  	
			<!--框架样式结束-->
		
		<script>
//上传图片
function upImage(obj) {
    require(['util'], function (util) {
      options = {
          multiple: false,//是否允许多图上传
          data:'',
          hash:1
          //hash为确定上传文件标识（可以以用户编号，标识为此用户上传的文件，系统使用这个字段值来显示文件列表），data为数据表中的data字段值，开发者根据业务需要自行添加
      };
      util.image(function (images) {            //上传成功的图片，数组类型 
          $("[name='thumb']").val(images[0]);
          $(".img-thumbnail").attr('src', images[0]);
      }, options)
    });
}

//移除图片 
function removeImg(obj) {
	var imgurl=$('input[name=thumb]').val();
	    $.post("{{U('rmfile')}}",{imgurl:imgurl},function(phpData){
    	
    },'json');
    $(obj).prev('img').attr('src', 'resource/images/nopic.jpg');
    $(obj).parent().prev().find('input').val('');
  
}
</script>
		
		
	</body>
</html>
